<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org" lang="zh-CN">

<head th:fragment="head">
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <title>年年有余</title>
    <link rel="stylesheet" type="text/css" href="/static/plugins/layui/css/layui.css">
    <link rel="stylesheet" type="text/css" href="/static/css/index.css">
    <script type="text/javascript" src="/static/plugins/layui/layui.js"></script>
</head>

<body>
    <div class="layui-header">
        <div class="head">
            <span style="border-left: 5px solid gray; padding-left: 5px;">当前位置：</span>
            <span id="position" href="javascript:;">首页</span>
            <span id="current-position" hidden="hidden" href="javascript:;"></span>
        </div>
        <ul class="layui-nav layui-layout-right">
            <li class="layui-nav-item" id="admin">
                <a href="javascript:;">
                    <i th:text="'  ' + ${session.username}" class="layui-icon layui-icon-username"></i></a>
                <dl class="layui-nav-child">
                    <dd>
                        <a href="javascript:;">修改密码</a>
                    </dd>
                    <dd>
                        <a href="/logout">退出</a>
                    </dd>
                </dl>
            </li>
        </ul>
    </div>
    <div class="layui-side">
        <div class="logo">
                <h1 style="font-size: 20px;text-align: center;">年年有余
                    <i class="layui-icon layui-icon-tree"></i>
                </h1>
        </div>
        <div class="layui-side-scroll">
            <ul class="layui-nav layui-nav-tree" lay-shrink="all">
                <li th:each="menu : ${session.menus}" th:class="'layui-nav-item ' + ${menu.order==1?'layui-this':''}">
                    <a th:if="${menu.childMenus} == null" th:inline="text" href="javascript:" onclick="menuFire(this)" th:src="${menu.url}"><i th:class="'layui-icon ' + ${menu.icon}"></i> &nbsp;&nbsp;&nbsp;&nbsp;[[${menu.menuName}]]</a>
                    <a th:if="${menu.childMenus} != null" th:inline="text" href="javascript:;"><i th:class="'layui-icon ' + ${menu.icon}"></i> &nbsp;&nbsp;&nbsp;&nbsp;[[${menu.menuName}]]</a>
                    <dl th:if="${menu.childMenus} != null" th:each="childMenu : ${menu.childMenus}" class="layui-nav-child">
                        <dd>
                            <a th:text="${childMenu.menuName}" href="javascript:;" onclick="menuFire(this)" th:src="${childMenu.url}"></a>
                        </dd>
                    </dl>
                </li>
            </ul>
        </div>
    </div>
    <!--主操作页面-->
    <div class="layui-body">
        <!--<div id="body" th:include="home/welcome :: html"></div>-->
        <iframe id="iframe-content" src="/welcome.html" frameborder="0"></iframe>
    </div>
    <script>
        //一般直接写在一个js文件中
        layui.use(['layer', 'element'], function() {
            var layer = layui.layer,
                element = layui.element;
            $ = layui.jquery;

        });
    </script>
    <script type="text/javascript">
        // 菜单点击
        function menuFire(obj) {
            //设置当前位置
            var tagName = $(obj).parent()[0].tagName;
            if (tagName == 'LI') {
                var position = $.trim($(obj).text());
                $('#position').text(position);
                $('#current-position').attr('hidden', 'hidden');
            } else {
                var position_curt = $.trim($(obj).parent().parent().parent().find('a').first().text()) +
                    ' - ';
                var position_child = $.trim($(obj).text());
                $('#position').text(position_curt);
                $('#current-position').text(position_child);
                $('#current-position').removeAttr('hidden','hidden');
            }
            //获取菜单src
            var src = $(obj).attr('src');
            // 设置iframe的src
            $('#iframe-content').attr("src", src);
        }

        //退出
        function logout() {
            $.get('/finance/public/index/login/logout', function(res) {
                if (res.code == 0) {
                    layer.msg(res.msg);
                    setTimeout(function() {
                        window.location.href = '/finance/public/index/login';
                    }, 500);
                }
            });
        }
    </script>
</body>

</html>